package com.woniuxy.controller;

import com.woniuxy.Exception.serviceException;
import com.woniuxy.entity.Attendance;
import com.woniuxy.entity.PageBean;
import com.woniuxy.entity.ResponseResult;
import com.woniuxy.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Response;

@RestController
public class AttendanceController {
   @Autowired
    AttendanceService attendanceService;

@PostMapping("/attendance/{pageIndex}/{pageSize}")
public ResponseResult<PageBean<Attendance>>getAllAttendance(@RequestBody Attendance attendance,
                                                            @PathVariable("pageIndex")int pageIndex,
                                                            @PathVariable("pageSize")int pageSize){

    ResponseResult<PageBean<Attendance>>responseResult;
    try {
        PageBean<Attendance>pageBean=attendanceService.getAllAttendance(attendance, pageIndex, pageSize);
        responseResult=new ResponseResult<>(200, "ok", pageBean);
        return responseResult;



    }catch (serviceException e) {
        responseResult = new ResponseResult<>(500, e.getMessage(), null);
        return responseResult;
    }





}







}
